home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
basic
/
qb_trap.zip
/
QB-TRAP.ASM
Wrap
Assembly Source File
|
1991-09-06
|
1KB
|
33 lines
;********** TrapInt.Asm - returns a value "trapped" within a specified range
;Copyright (c) 1989 Ethan Winer
;Syntax - LOCATE TrapInt%(Y%, 1, 25), TrapInt%(X%, 1, 80)
.Model Medium
.Code
Include Mixed.Inc
HProc TrapInt, Value:Ptr, Min:Ptr, Max:Ptr
Mov SI,Value ;get the address for Value
Mov AX,[SI] ;put it in AX assuming it is within range
Mov SI,Min ;get the address for the minimum acceptable value
Cmp AX,[SI] ;see if AX is indeed equal or larger
Jge CheckMax ;it is, now check if it's within the upper limit
Mov AX,[SI] ;out of range, so assign it to the minimum
Jmp Short Exit ;and skip the remaining test
CheckMax:
Mov SI,Max ;get the address for the maximum acceptable value
Cmp AX,[SI] ;see if AX is within the upper limit
Jle Exit ;yes, exit with the incoming value as the result
Mov AX,[SI] ;no, assign AX to the maximum limit
Exit:
HRet ;return to BASIC with the function output in AX
HEndp
End